﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="copyright" content=""/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>名片-编辑</title>
    <link href="<%=path%>/favicon.ico" rel="shortcut icon">
    <link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/public.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/activity.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/marketing.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/style_list.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/custom.css" />

    <link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
    <style>
        #qrcode img{
            width:100%;
            /* margin:10%; */
            border:5px solid #fff;
        }
        /* #qrcode {
             background: url(../images/k_ewm_border.png) no-repeat;
             background-size: 100% 100%;
             width: 121px;
             height: 121px;
        } */
    </style>
</head>
<body  class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="container-fluid">         <div class="row">
        <!-- <div class="col-md-12">
            步骤
            <div hidden="" class="progress" style="width:400px;">
                <div class="progress-bar progress-bar-warning" role="progressbar"
                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                    <span class="sr-only_1">1</span>
                    <p class="x_color_bz">选择模板</p>
                </div>
                <div class="progress-bar progress-bar-warning" role="progressbar"
                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                    <span class="sr-only_1">2</span>

                    <p class="x_color_bz x_color_dq" style="color:#ffc105;">编辑内容</p>
                </div>
                <div class="progress-bar progress-bar-info" role="progressbar"
                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                    <span class="sr-only_2">3</span>
                    <p class="x_color_bz x_color_dq">分享设置</p>
                </div>
                <div class="progress-bar progress-bar-info" role="progressbar"
                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                    <span class="sr-only_2">3</span>
                    <p class="x_color_bz">名片预览</p>
                </div>
                <div class="progress-bar progress-bar-info" role="progressbar"
                     aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
                    <span class="sr-only_2">√</span>
                    <p class="x_color_bz">分享</p>
                </div>
            </div>
            步骤end
        </div> -->
        <div class="col-md-12 ">
            <!--内容左侧-->
            <div class="x_basics_list x_basics x_floatl x_w  x_padding10">
            <div id="qrcode"></div>
               
                <div class="x_basics x_floatl x_l">
                <!--业务介绍-->
                        <div class="x_list_style">
                            <ul class="x_title">
                                <li class="x_list01" id="bm_ye_wu_gou">
                                    <img src="<%=path%>/images/marketing/s_check.png" class="s_check" _id="1" alt="2"/>
                                    <i>业务介绍</i>
                                </li>
                                <li class="bm_yewu"><h3 style="color: #03a9f4; text-decoration: underline;">选择列表</h3></li>
                            </ul>
                            <div class="clear-shadow"></div>
                            <div class="x_list_center01" >
                                <div class="panel panel-default" style="background-color:#f4f7f9;">
                                    <div class="panel-body">
                                        <ul>
                                            <li>好伦哥的业务介绍<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="x_list_center02" style="display:block;">
                                <div class="panel panel-default" style="background-color:#f4f7f9;">
                                    <div class="panel-body">
                                        <ul id="bm_yewuxian">
                                            <%--  <li>金百万烤鸭（亦庄店）<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li>  --%>
                                        </ul>
                                    </div>
                                </div>
                                <div class="clear-shadow"></div>
                            </div>
                        </div>
                        <!--业务介绍end-->
                <!--业务权限控制-->
                        <div class="x_list_style">
                            <ul class="x_title">
                                <li class="x_list01" id="bm_ye_wu_gou">
                                    <img src="<%=path%>/images/marketing/s_check.png" class="s_check" _id="1" alt="2"/>
                                    <i>员工是否可设置</i>
                                </li>
                                          <h3>
								                <input  type="radio" checked="" value="1" id="business_tag1" name="business_tag">是
								                 &nbsp;&nbsp;&nbsp;&nbsp;
								                <input type="radio" value="2" id="business_tag2" name="business_tag">否
								          </h3>  
								           
								                                
						    </ul>
                            <div class="clear-shadow"></div>
                            
                        </div>
                        <!--业务权限end-->
                
                     <!--我的推荐介绍-->
                        <div class="x_list_style">
                            <ul class="x_title">
                                <li class="x_list03" id="bm_tui_tui">
                                    <img src="<%=path%>/images/marketing/s_check.png" class="s_check" _id="1" alt="3"/>
                                    <i>我推荐</i>
                                </li>
                                <li class="bm_wotuijian"><h3 style="color: #03a9f4; text-decoration: underline;">选择我推荐</h3></li>
                            </ul>
                            <div class="clear-shadow"></div>
                            <div class="x_list_center03 " >
                                <div class="panel panel-default" style="background-color:#f4f7f9;">
                                    <div class="panel-body">
                                        <ul>
                                            <%-- <li>金百万烤鸭（亦庄店）<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li> --%>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="x_list_center04" style="display:block; ">
                                <div class="panel panel-default" style="background-color:#f4f7f9;">
                                    <div class="panel-body">
                                        <ul id="bm_tuijan">
                                            <%-- <li>金百万烤鸭（亦庄店）<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li>
                                            <li>金百万烤鸭（亦庄店）<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li> --%>
                                        </ul>
                                    </div>
                                </div>

                            </div>
                        </div>
                        <!--我的推荐介绍end-->
                     <!--活动介绍权限-->
                        <div class="x_list_style">
                            <ul class="x_title">
                                <li class="x_list01" id="bm_ye_wu_gou">
                                    <img src="<%=path%>/images/marketing/s_check.png" class="s_check" _id="1" alt="2"/>
                                    <i>员工是否可设置</i>
                                </li>
                                         <h3>
								                <input  type="radio" checked="" value="1" id="activity_tag1" name="activity_tag">是
								                 &nbsp;&nbsp;&nbsp;&nbsp;
								                <input type="radio" value="2" id="activity_tag2" name="activity_tag">否
								          </h3>                            
						    </ul>
                            <div class="clear-shadow"></div>
                            
                        </div>
                        <!--活动介绍权限end-->
                        
                        <!--选择员工 -->
                             
                        <div class="x_list_style">
                            <ul class="x_title">
                                <li class="x_list01" id="bm_ye_wu_gou">
                                    <img src="<%=path%>/images/marketing/s_check.png" class="s_check" _id="1" alt="2"/>
                                    <i>选择员工</i>
                                </li>
                                         <h3>
								                <input  type="radio" checked="" value="all" id="department1" name="optionsRadios">全部员工
								                 &nbsp;&nbsp;&nbsp;&nbsp;
								                <input type="radio" value="" id="department2" name="optionsRadios">选择部门
								          </h3>                           
						    </ul>
                            <div class="clear-shadow"></div>
                            
                        </div>
                        <!--选择员工end  -->
                        <div class="clear-shadow"></div>

                        <!--新创建通知-->
                        <div class="x_list_style">
                            <ul class="x_title">
                                <li class="x_list01" id="bm_ye_wu_gou">
                                    <img src="<%=path%>/images/marketing/s_check.png" class="s_check" _id="1" alt="2"/>
                                    <i>新创建通知</i>
                                </li>
                                         <h3>
								                <input  type="radio" checked="" value="no" id="inform1" name="optionsRadios">不通知
								                 &nbsp;&nbsp;&nbsp;&nbsp;
								                <input type="radio" value="yes" id="inform2" name="optionsRadios">通知
								          </h3>                          
						    </ul>
                            <div class="clear-shadow"></div>
                            
                        </div>
                        <!--新创建通知end-->
                  <div class="clear-shadow"></div>
                        <div class="x_top10">
                            <form role="form" >
                                <div class="row">
                                    <div class=" x_floatl ">
                                        <a class=" x_button_l " style="color: #03a9f4;" href="javascript:;" id="card_quxiao">取消</a>
                                    </div>
                                  
                                   <div class="x_floatr">
                                        <a class=" x_button_y " href="javascript:;">提交</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="clear-shadow"></div>
                  
                </div>
                <!--活动预览部分end-->
                <div class="x_floatr x_r x_top10 x_padding10" style="margin-top:20px;">
                    <div class="x_editor k_editor form-horizontal">
                        <!-- <form role="form" class="form-horizontal" > -->
                        

                  
                        
                        <!-- </form> -->
                    </div>
                </div>
            </div>
            <!--内容左侧end-->
        </div>
    </div>
    </div>
</div>

<!-- 添加账号弹框 -->
<div class="x_popup">
    <div class="issue x_xk_issue">
        <span><img src="<%=path%>/images/marketing/close.png" /></span>
        <h4>扫一扫 立刻分享</h4>
        <p><img src="<%=path%>/images/marketing/code.jpg" /></p>
    </div>
</div>



<!-- 删除活动弹框 -->
<div class="s_popup_delect">
    <div class="issue_delect">
        <span><img id="bm_md_cha" src="<%=path%>/images/marketing/close.png" /></span>
        <h4><img src="<%=path%>/images/marketing/warning.png" /> 删除门店提示</h4>
        <p>确定要删除此门店吗</p>
        <ol class="fix">
            <li><a href="javascript:;" class="s_cancel" id="bm_shan_men">取消</a></li>
            <li><a href="javascript:deleteStore();" id="bm_shan_que">确定</a></li>
        </ol>
    </div>
</div>



<!-- 门店弹窗！！！！！！ -->
<div class="x_popup_add">
    <div class="issue_add">
        <span><img src="<%=path%>/images/marketing/close.png" /></span>
        <h4>选择部门</h4>
     
        <div class="k_box3">
            <div class="k_record">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content" style="max-height:400px;overflow-y:auto;">
                                <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="4">
                                    <thead>
                                    <tr>
                                        <th data-toggle="true">&nbsp;&nbsp;部门名称</th>
                                       
                                    </tr>
                                    </thead>
                                    <tbody id = "bm_cstore">

                                    </tbody>

                                </table>

                                <!--分页  -->
                            

                            </div>
                        </div>
                    </div>
                </div>
                <!----->
            </div>

            <ol class="fix x_qx" style="margin-top:-20px;">
                <li id = "bm_cqu"><a href="javascript:;" class="s_cancel" id = "bm_cqu">取消</a></li>
                <li id="bm_queque"><a href="javascript:;" >确定</a></li>
            </ol>

        </div>
    </div>
</div>
<!-- 添加账号弹框end -->
<!-- 推送活动 bj33-->
<div class="m_xpopups J_xactivity">
    <div class="m_xpropell">
        <div class="wire"></div>
        <div class="title"><i class="J_xsutup"><img id="bm_ca1" src="<%=path%>/images/close.png" /></i>选择推送活动(最多只能选5个)</div>
        <div>
        <ul class="nav nav-tabs">
            <li class="active">
                <a data-toggle="tab" href="#tab1" aria-expanded="true">选择活动</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab2" aria-expanded="false">自定义链接</a>
            </li>
        </ul>
    </div>
    <div class="tab-content">
        <div id="tab1" class="tab-pane active">
            <div class="m_xswung">
                <div class="caption">
                    <span>活动概览</span>
                    <span>活动标签</span>
                    <span>统计值</span>
                    <span>状态</span>
                </div>
                <ul class="flexibe" id="activity_list">


                </ul>
            </div>
            <div class="m_xpages">
                <div class="mian">
                    <span>显示行数</span> <select><option>5</option>
                    <option>10</option>
                    <option>20</option></select> <span class="bm_tiao">共80条</span> <span class="bm_ye">1/4页</span> <a
                        href="javascript:;" class="prev">上一页</a> <a href="javascript:;"
                                                                    class="next">下一页</a> <span>前往</span> <input type="text" value="1"
                                                                                                                class="text"> <span>页</span>
                </div>
                <div class="m_xbutton m_xfinish">
                    <a href="javascript:;" class="white" id="bm_ququxiao">取消</a>
                    <a href="javascript:;" onclick="childFinish()" id="bm_wanwa">完成</a>
                </div>
            </div>
        </div>
        <div id="tab2" class="tab-pane"><%--555--%>
            <div class=" form-horizontal">
                <div class="col-sm-1"></div>
                <div class="col-sm-11"><h2>编辑H5展示内容</h2>
                </div>
                <div class="form-group">
                    <div class="col-lg-1"></div>
                    <div class="col-lg-4"><%--bj003--%>
                        <div class="x_img_sc">
                            <img id="share_pic" style="width: 100px; height: 100px"src="<%=path%>/images/marketing/img_p.png">
                        </div>
                        <form  id='share_image' enctype='multipart/form-data'>
                            <input type="file" accept="image/gif,image/jpeg,image/x-png" id="inputfile" onchange="fileloadon()" name="filepath"
                                   style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99;">
                            <p style="line-height:80px;color: #bdbdbd;"> &nbsp;&nbsp;(上传图片要求：尺寸为120×120像素，大小10K左右)</p>
                        </form>
                    </div>
                    <div class="clear-shadow col-lg-7"></div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1"></div>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id = "h5_biaoti" placeholder="请输入标题" >
                    </div>
                    <div class="clear-shadow"></div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1"></div>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id = "h5_jianjie" placeholder="请输入简介" >
                    </div>
                    <div class="clear-shadow"></div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1"></div>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id = "h5_url" placeholder="请输入地址链接，仅支持移动端" >
                    </div>
                    <div class="clear-shadow"></div>
                </div>
                <div class="m_xbutton m_xfinish">
                    <a href="javascript:;" class="white" id="bm_ququxiao">取消</a>
                    <a href="javascript:;" onclick="childFinish()" id="bm_wanwa">完成</a>
                </div>
            </div>
        </div>

    </div>


    </div>
</div>

<!-- 编辑门店 -->

<div class="s_popup_delect2">
    <div class="s_consum">
        <p id="dialog_title"><img src="<%=path%>/images/marketing/s_tick.png" /> 活动启用成功</p>
    </div>
</div>
<%--搜索用户弹窗--%><%--bj1--%>
<div class="x_selectuser" id="selectuser">
    <div class="issue_selectuser">
        <span><img src="<%=path%>/images/marketing/close.png" /></span>
        <h4>搜索用户</h4>
        <ul class="s_role_condition fix ">
            <li>关键字<input placeholder="输入关键字，支持模糊搜索" type="text" id="bm_nameOrtel"></li>
            <li><i><img src="<%=path%>/images/marketing/icon_search.png" id="bm_mohu"></i></li>
        </ul>
        <div class="k_box3">
            <div class="k_record">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content" style="max-height:400px;overflow-y:auto;">
                                <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="4">
                                    <thead>
                                    <tr>
                                        <th data-toggle="true">姓名</th>
                                        <th>电话</th>
                                        <th>部门</th>
                                        <th>门店</th>
                                    </tr>
                                    </thead>
                                    <tbody id = "bm_userlist">

                                    </tbody>

                                </table>

                                <!--分页  -->
                                <div class="m_xpages" style="width:100%;margin:0;padding:20px;">
                                    <div class="mian">
                                        <span>显示行数</span> <select><option>5</option>
                                        <option>10</option>
                                        <option>20</option></select> <span class="bm_tiao">共0条</span> <span class="bm_ye">0/0页</span> <a
                                            href="javascript:;" class="prev">上一页</a> <a href="javascript:;"
                                                                                        class="next">下一页</a> <span>前往</span> <input type="text" value="1"
                                                                                                                                    class="text"> <span>页</span>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <!----->
            </div>

            <ol class="fix x_qx" style="margin-top:-20px;">
                <li id = "user_quxiao"><a href="javascript:;" class="s_cancel" id = "user_quxiao">取消</a></li>
                <li id="user_ok"><a href="javascript:;" >确定</a></li>
            </ol>

        </div>
    </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/lengthlimit.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/InputLimitedByidandlength.js"></script>
<script>
          




    $(document).on('click','#bm_user_id',function(){
        $("#selectuser, .issue_selectuser").show();

    })
    $(document).on('click','.s_check',function(){
        var img_path = $(this).attr("src");
        var ids = $(this).attr("alt");
        var show_id = "info" + ids;
        if(img_path=="<%=path%>/images/marketing/s_check.png"){
            $(this).attr("src","<%=path%>/images/marketing/s_check_no.png");
            $("#"+show_id+"").hide();
            if(ids==1){
                $("#info11").hide();
            }
        }else{
            $(this).attr("src","<%=path%>/images/marketing/s_check.png");
            $("#"+show_id+"").show();
            if(ids==1){
                $("#info11").show();
            }
        }

        /* $(".x_popup_editor,.issue_editor").show(); */
    });


    //点击取消弹框消失（编辑门店）
    $('#bm_md_menmen').click(function(){
    });
    //点击取消弹框消失（添加门店）
    $('#bm_md_qxx').click(function(){
        $(".x_popup_t,.issue_t").hide();
    });

    $('.J_xcode').click(function () {
        var $this = $(this),
            _this = this,
            i = 60;
        _this.disabled = 'disabled';
        clearInterval(repeat);
        var repeat = setInterval(function () {
            i--;
            if (i == 0) {
                _this.disabled = false;
                $this.removeClass('gray').val('获取验证码');
                clearInterval(repeat);
            } else {
                $this.addClass('gray').val(i + 's后重新获取');
            }
        }, 1000);
    })
    $('.J_xcodes').click(function () {
        var $this = $(this),
            _this = this,
            i = 60;
        _this.disabled = 'disabled';
        clearInterval(repeat);
        var repeat = setInterval(function () {
            i--;
            if (i == 0) {
                _this.disabled = false;
                $this.removeClass('gray').val('获取验证码');
                clearInterval(repeat);
            } else {
                $this.addClass('gray').val(i + 's后重新获取');
            }
        }, 1000);
    })

    /* $(".x_list01").click(function () {
        $(".x_list_center01").show();
        $(".x_list_center02").hide();

        $(".x_list01 h3").css({ "color": "#03a9f4", "text-decoration": "underline" });
        $(".x_list02 h3").css({ "color": "#666666", "text-decoration": "none" });
    }); */

    $("#department2").click(function () {
        /*  $(".x_list_center01").hide();
         $(".x_list02 h3").css({ "color": "#03a9f4", "text-decoration": "underline" });
         $(".x_list01 h3").css({ "color": "#666666", "text-decoration": "none" }); */
        $(".x_list_center02 ,.x_popup_add,.issue_add").show();
        $(".x_CheckBox_pic").click(function () {
            var cutsrc = $(".x_CheckBox_pic").attr('src');
            if (cutsrc == "<%=path%>/images/marketing/s_check_no.png") {
                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check.png');
                $(".ibox-content").find(".x_CheckBox").attr('src', '<%=path%>/images/marketing/s_check.png');
            } else {
                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check_no.png');
                $(".ibox-content").find(".x_CheckBox").attr('src', '<%=path%>/images/marketing/s_check_no.png');
            }
        });
        var bool = false;
        $(".ibox-content").find(".x_CheckBox").click(function () {
            if ($(this).attr("src") == "<%=path%>/images/marketing/s_check_no.png")
                $(this).attr('src', '<%=path%>/images/marketing/s_check.png');
            else
                $(this).attr('src', '<%=path%>/images/marketing/s_check_no.png');

            var rr = $(".ibox-content").find(".x_CheckBox");
            if (rr != 0) {
                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check_no.png');
            } else {
                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check.png');
            }
            for (i = 0; i < 3; i++) {
                if (rr[i].attributes[1].nodeValue == "<%=path%>/images/marketing/s_check_no.png") {
                    bool = true;
                    break;
                }
            }

            if (bool == false) {
                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check.png');
            } else {
                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check_no.png');
            }
        });



    });
    $('.issue_add > span').click(function () {
        $('.x_popup_add,.issue_add').hide();
        $(".x_popup_editor,.issue_editor").hide();
    });
    //此处修改，关闭搜索用户框
    $('.issue_selectuser > span').click(function () {
        $('.x_selectuser,.issue_selectuser').hide();
    });

    $(".x_button_add").click(function () {
        $('#bm_qming').val('');
        $('#bm_qaddress').val('');
        $('#bm_qphone').val('');
        $(".x_popup_t,.issue_t").show();
        $(".x_popup_editor,.issue_editor").hide();
    })
    $(".issue_t span").click(function () {
        $(".x_popup_t,.issue_t").hide();
        $(".x_popup_editor,.issue_editor").hide();
    })

    //点击编辑弹出编辑窗口
    /* $(".x_editor_bj").click(function () {
        $(".x_popup_editor,.issue_editor").show();
        $(".x_popup_t,.issue_t").hide();
    }) */
    $(".issue_editor span").click(function () {
        $(".x_popup_editor,.issue_editor").hide();
        $(".x_popup_t,.issue_t").hide();
    })



    $(".x_list03").click(function () {
        /*     $(".x_list_center03").show();
            $(".x_list_center04").hide();

            $(".x_list03 h3").css({ "color": "#03a9f4", "text-decoration": "underline" });
            $(".x_list04 h3").css({ "color": "#666666", "text-decoration": "none" });*/
    });

    $(".x_list04").click(function () {
        /* $(".x_list_center04").show();
        $(".x_list_center03").hide();
        $(".x_list04 h3").css({ "color": "#03a9f4", "text-decoration": "underline" });
        $(".x_list03 h3").css({ "color": "#666666", "text-decoration": "none" }); */
    });

</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/actionCustomer.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/qrcode.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>

<script type="text/javascript">
		var  cid;
		var  businessIds;
		var  business_tag;
		var  activityIds;
		var  activity_tag; 
		var  department=""; 
		var  inform;

    $(function() {
    	
    
    	//业务权限
    	$("#business_tag1").click(function(){
    		
    		business_tag=$("#business_tag1").val();
    		console.log(business_tag);
		});
    	$("#business_tag2").click(function(){   		
    		business_tag=$("#business_tag2").val();
    		console.log(business_tag);
		});
    	
    	//活动权限
        $("#activity_tag1").click(function(){
    		
        	activity_tag=$("#activity_tag1").val();
    		console.log(activity_tag);
		});
    	$("#activity_tag2").click(function(){   		
    		activity_tag=$("#activity_tag2").val();
    		console.log(activity_tag);
		});
    	
    	 //短信通知
    	 $("#inform1").click(function(){
     		
    		 inform=$("#inform1").val();
     		console.log(inform);
 		});
     	$("#inform2").click(function(){   		
     		inform=$("#inform2").val();
     		console.log(inform);
 		});
    	
     	//选择员工
     	
     	 $("#department1").click(function(){
      		
     		department=$("#department1").val();
     		console.log(department);
 		});
     	$("#department2").click(function(){   		
     		$('#bm_men_dian img').attr('src','<%=path%>/images/marketing/s_check.png');
            goumen = 0;
            microPortal();
            bmstore();
 		});
    	
		
	});





    /* 二维码名片生成 */

    var qrcode = new QRCode(document.getElementById("qrcode"), {
        width : 125,
        height : 125
    });

    function makeCode(){

        var a,b=$("#bm_cname").val();
        var c=$("#name").val();
        var d=$("#bm_cjob").val();
        var e=$("#adr").val();
        var f=$("#focusedInput").val();
        var g=$("#bm_cmoblie").val();
        var h=$("#home").val();
        var i=$("#url").val();
        var j=$("#bm_cmail").val();
        var k=$("#bday").val();


        a = "BEGIN:VCARD";
        if( b!=null || b!=""){
            a+="\r\nN:"+b+";";
        }
        if( d!=null || d!=""){
            a+="\r\nTITLE:"+d;
        }
        if( g!=null || g!=""){
            a+="\r\nTEL;CELL,VOICE:"+g;
        }
        if( j!=null || j!=""){
            a+="\r\nEMAIL;PREF;INTERNET:"+j;
        }
        if(f!=null || f!=""){
            a+="\r\nORG:"+f;
        }
        a += "END:VCARD";
        /* a = "BEGIN:VCARD
            VERSION:3.0
            FN:任侠
            TEL;CELL;VOICE:15201280000
            TEL;WORK;VOICE:010-62100000
            TEL;WORK;FAX:010-62100001
            EMAIL;PREF;INTERNET:lzw#lzw.me
            URL:http://lzw.me
            orG:志文工作室
            ROLE:产品部
            TITLE:CTO
            ADR;WORK;POSTAL:北京市朝阳区北四环中路35号;100101
            REV:2012-12-27T08:30:02Z
            END:VCARD"; */
        if (!a) {
            console.log("00000000000000000000");
            return;
        }
        //console.log(a);
        qrcode.makeCode(a);
    }
    //点击暂存
    $('.x_button_y').click(function(){
        makeCode();
        zansave();
    });

    //从其他页面进入该页面是执行方法
    $(function(){
        $(document).on("keyup","#focusedInput,#bm_cname,#bm_cjob,#bm_cmoblie,#bm_czuoji,#bm_cmail,#bm_cweixin,#bm_cweibo,#bm_cqq,#bm_cziding",function(e){

            reloadLeft();
        });
        cardId = getQueryString("card_id");
        if(StringEmpty(cardId)){
            queryCard(cardId);

        }else{
            microPortal();
        }


    });
    //进入门店后点击取消
    $('#bm_cqu').click(function(){
        $('.x_popup_add,.issue_add').hide();
    });

    //此处修改，进入用户搜索点击取消关闭
    $('#user_quxiao').click(function(){
        $('.x_selectuser,.issue_selectuser').hide();
    });

    var access_token=$.cookie('access_token');
    var cid=$.cookie('cid');
    var uid=$.cookie('uid');
    var companyName;
    //var headPicture;
    var mpname;
    var job;
    var mobile;
    var zuoMobile;
    var mail;
    var weixin;
    var weibo;
    var qq;
    var userdefined;
    //var erCode;
    var mdStore;
    //门店参数
    var store_names=new Array();
    var store_ids=new Array();
    var store_phone=new Array();
    var store_address=new Array();

    //用户参数
    var user_ids =  new Array();
    var user_name =  new Array();
    var user_phone =  new Array();

    //标记编辑活动是否保存
    var save_tag=false;

    var save_xia=false;
    var cardId;
    

    var qrcode_pic;
    var head_pic;



    //暂存后点击下一步
    $('#md_x_button').click(function(){
        save_xia = true;
        zansave();
        <%-- if(save_tag == true){
            window.location.href = "<%=path%>/api/bm/ui/cardPreview?card_id="+cardId;
        }else{
            showDialog("请先保存");
        } --%>
    });
    //编辑名片时边显示
    function reloadLeft(){
        //企业名称
        companyName = $("#focusedInput").val();
        $("#cc_name").text(companyName);
        //姓名
        mpname = $("#bm_cname").val();
        $("#cc_nname").text(mpname);
        //职务
        job = $("#bm_cjob").val();
        $("#cc_job").text(job);
        //座右铭
        userdefined = $("#bm_cziding").val();
        if(StringEmpty(userdefined)){
            var html = '<img src="<%=path%>/images/marketing/icon_plume.png"/>&nbsp;&nbsp;';
            $("#cc_zuoyou").html(html+userdefined);
        }else{
            $('#cc_zuoyou').html('');
        }

        //手机号码
        mobile = $("#bm_cmoblie").val();
        var html = '<img src="<%=path%>/images/marketing/icon11.png" />&nbsp;&nbsp;';
        $("#cc_phone").html(html+mobile);

        //座机
        zuoMobile = $("#bm_czuoji").val();
        if(StringEmpty(zuoMobile)){
            var html = '<img src="<%=path%>/images/marketing/icon22.png" />&nbsp;&nbsp;';
            $("#cc_zuoji").html(html+zuoMobile);
        }else{
            $('#cc_zuoji').html('');
        }

        //邮箱
        mail = $("#bm_cmail").val();
        if(StringEmpty(mail)){
            var html = '<img src="<%=path%>/images/marketing/icon33.png" />&nbsp;&nbsp;';
            $("#cc_mail").html(html+mail);
        }else{
            $('#cc_mail').html('');
        }

        //微信
        weixin = $("#bm_cweixin").val();
        if(StringEmpty(weixin)){
            var html = '<img src="<%=path%>/images/marketing/icon55.png" />&nbsp;&nbsp;';
            $("#cc_weixin").html(html+weixin);
        }else{
            $('#cc_weixin').html('');
        }


        //微博
        weibo = $("#bm_cweibo").val();
        if(StringEmpty(weibo)){
            var html = '<img src="<%=path%>/images/marketing/icon66.png" />&nbsp;&nbsp;';
            $("#cc_weibo").html(html+weibo);
        }else{
            $('#cc_weibo').html('');
        }


        //qq
        qq = $("#bm_cqq").val();
        if(StringEmpty(qq)){
            var html='<img src="<%=path%>/images/marketing/icon44.png" />&nbsp;&nbsp;';
            $("#cc_qq").html(html+qq);
        }else{
            $('#cc_qq').html('');
        }

    }

    //点击取消
    $('#card_quxiao').click(function(){
        window.location.href = "<%=path%>/api/bm/ui/cardHome";
    });

    //暂存
    function zansave(){

        

      
            
                    saveCompanyCard();
                    console.log("微门户勾选状态："+goumen);
                    //修改微门户门店
                    if(goumen=="0"){
                        updateMicro();
                        $('#info11').show();
                        $('#info1').show();
                    }
       
    }
    var goumen=0;
    var gouye=0;
    var goutui=0;

    //判断是否勾选(门店)
    $(document).on('click','#bm_men_dian .s_check',function(){
        var src = $(this).attr("src");
        console.log("src--->"+src);
        if(src=="<%=path%>/images/marketing/s_check_no.png"){
            <%-- alert(11);
            $(this).attr('src','<%=path%>/images/marketing/s_check.png'); --%>
            goumen = 1;
        }else {
            <%-- 	alert(22);
                $(this).attr('src','<%=path%>/images/marketing/s_check_no.png'); --%>
            goumen = 0;
            microPortal();
        }
    });
    //判断是否勾选(业务)
    $(document).on('click','#bm_ye_wu_gou img',function(){
        var src = $(this).attr("src");
        if(src=="<%=path%>/images/marketing/s_check.png"){
            <%--  $('#bm_ye_wu_gou img').attr('src','<%=path%>/images/marketing/s_check_no.png'); --%>
            gouye = 0;
        }else {
            <%--  $('#bm_ye_wu_gou img').attr('src','<%=path%>/images/marketing/s_check.png'); --%>
            gouye = 1;
        }
    });
    //判断是否勾选(推荐)
    $(document).on('click','#bm_tui_tui img',function(){
        var src = $(this).attr("src");
        if(src=="<%=path%>/images/marketing/s_check.png"){
            <%-- $('#bm_tui_tui img').attr('src','<%=path%>/images/marketing/s_check_no.png'); --%>
            goutui = 0;
        }else {
            <%-- $('#bm_tui_tui img').attr('src','<%=path%>/images/marketing/s_check.png'); --%>
            goutui = 1;
        }
    });


    //bj7
    function saveCompanyCard(){
        var mdstore= $('#bm_md_list').children();
        var md_str = '';
        for(var i = 0 ; i < mdstore.length ;i++){
            if(i == mdstore.length - 1){
                md_str += $(mdstore[i]).text();
            }else{
                var z = $(mdstore[i]).text() + ",";
                md_str += z;
            }
        }
        
        
        
        //业务id
        var yeIds = new Array();
        $('.deleteye').each(function(j,d){
            var yyid = $(this).attr('yid');
            yeIds[j]=yyid;
        });
        definedIds = yeIds.join(",");

        //推荐id
        var tuiIds = new Array();
        //	var sysIds;
        $('.deletehuo').each(function(j,d){
            var ttuid = $(this).attr('tid');
            tuiIds[j]=ttuid;
        });
        sysIds=tuiIds.join(",");
        var jsonParam={};
        jsonParam.access_token=access_token;
        jsonParam.cid=cid;
        jsonParam.uid=uid;
        jsonParam.businessIds=businessIds;
        jsonParam.activityIds=activityIds;
        jsonParam.activityTag=activity_tag;
        jsonParam.departmentIds=departmentIds;
        jsonParam.inform=inform;
       
        var url = "<%=path%>/CardActivityAuthor/create";
        if(department!=null){
        
        	$.post(url,jsonParam,function(data){
           
            	promptDialog("编辑成功！！");

            });
        }else{
        	
        	 
                 promptDialog("提交失败");
             
        }
        

    }

    //二次点击暂存时进行的修改操作  bj8
    function updateCompanyCard(){
        var mdstore= $('#bm_md_list').children();
        var md_str = '';
        for(var i = 0 ; i < mdstore.length ;i++){
            if(i == mdstore.length - 1){
                md_str += $(mdstore[i]).text();
            }else{
                var z = $(mdstore[i]).text() + ",";
                md_str += z;
            }
        }
        var url = "<%=path%>/businessCard/updatecard";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "companyName" : companyName,
            "name" : mpname,
            "job" : job,
            "mobile" : mobile,
            "zuoMobile" : zuoMobile,
            "mail" : mail,
            "weixin" : weixin,
            "weibo" : weibo,
            "qq" : qq,
            "userdefined" : userdefined,
            "mdStore" : md_str,
            "id" : cardId,
            "headPicture":head_pic,
            "bak1" : goumen,
            "bak2" : gouye,
            "bak3" : goutui,
            "type" : type,
            "erCode":qrcode_pic,
            "userId" : user_id
        },function(data){
            console.log("goumen------->"+goumen);
            console.log("gouye------->"+gouye);
            console.log("goutui------->"+goutui);
            if(data.status == 200){
                save_tag=true;
                if(gouye == "0" && goutui == "0"){
                    //业务id
                    var yeIds = new Array();
                    // var definedIds;
                    $('.deleteye').each(function(j,d){
                        var yyid = $(this).attr('yid');
                        yeIds[j]=yyid;
                    });
                    definedIds = yeIds.join(",");
                    //推荐id
                    var tuiIds = new Array();
                    //	var sysIds;
                    $('.deletehuo').each(function(j,d){
                        var ttuid = $(this).attr('tid');
                        tuiIds[j]=ttuid;
                    });
                    sysIds=tuiIds.join(",");
                    console.log("修改业务id:----------"+definedIds);
                    console.log("修改推荐id:----------"+sysIds);

                    yeupdateActivity(cardId);
                    tuiupdateActivity(cardId);

                }else if(goutui == "0" && gouye != "0"){
                    //推荐id
                    var tuiIds = new Array();
                    //var sysIds;
                    $('.deletehuo').each(function(j,d){
                        var ttuid = $(this).attr('tid');
                        tuiIds[j]=ttuid;
                    });
                    sysIds=tuiIds.join(",");
                    definedIds=null;
                    console.log("推荐id:----sysIds------"+sysIds);
                    yeuTag=true;
                    yeupdateActivity(cardId);
                    tuiupdateActivity(cardId);
                }else if(goutui != "0" && gouye == "0"){
                    //业务id
                    var yeIds = new Array();
                    //  var definedIds;
                    $('.deleteye').each(function(j,d){
                        var yyid = $(this).attr('yid');
                        yeIds[j]=yyid;
                    });
                    definedIds = yeIds.join(",");
                    sysIds = null;
                    console.log("业务id:----------"+definedIds);
                    tuiTag=true;
                    yeupdateActivity(cardId);
                    tuiupdateActivity(cardId)
                }else if(goutui != "0" && gouye != "0"){
                    definedIds=null;
                    sysIds=null;
                    console.log("业务id:----------"+definedIds);
                    console.log("推荐id:----------"+sysIds);
                    yeupdateActivity(cardId);
                    tuiupdateActivity(cardId);
                }

                /* cardHtml(data.data); */
            }else if(data.error_code == "10013"){
                promptDialog(data.message);
            }else{
                promptDialog("修改信息失败！！！");
            }
        });
    }

    //门店名称
    var mdname;
    //地址
    var address;
    //电话
    var phone;
    //门店id
    var id;
    //关键字
    var key_word;
    //名片id

    var activity_id;

    //点击选择门店bj4
    $('#bm_cmen').click(function(){
        $('#bm_men_dian img').attr('src','<%=path%>/images/marketing/s_check.png');
        goumen = 0;
        microPortal();
        bmstore();
    });

    //点击搜索门店
    $('#bm_csous').click(function(){
        bmstore();
    });
    //点击索搜所有用户
    $('#bm_mohu').click(function(){
        userlist();
    });
    //查询所有用户bj2
    function userlist(){
        if(listIndex != 4){
            listIndex = 0;
        }
        listIndex = 4;
        //获取关键字
        key_word = $('#bm_nameOrtel').val();
        var url = "<%=path%>/api/account/getUserAllByNameOrPhone";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "key_word" : key_word,
            "startIndex" : startIndex,
            "page_size" : pageSize
        },function(data){

            if(data.status == 200){
                userlistHtml(data.data);
                page(data.totalCount);
            }/* else if(data.error_code == 1){

    		} */else{
                $('#bm_userlist').html('');
            }

        });
    }
    //查询所有门店
    function bmstore(){
    	console.log("chxun")
        if(listIndex != 1){
            listIndex = 0;
        }
        listIndex = 1;
        //获取关键字
        key_word = $('#bm_keyword').val();
        var url = "<%=path%>/api/department/getAllDepartment";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "key_word" : key_word,
            "startIndex" : startIndex,
            "page_size" : pageSize
        },function(data){

            if(data.status == 200){
                storeHtml(data.data);
                page(data.totalCount);
            }/* else if(data.error_code == 1){

    		} */else{
                $('#bm_cstore').html('');
            }

        });
    }
    //编辑时获取门店id
    $(document).on('click','.x_editor_bj',function(){
        storeId = $(this).attr("sid");
        queryOne();
        $(".x_popup_editor,.issue_editor").show();
    });
    //编辑门店后点确定触发接口方法
    $('#bm_qued').click(function(){
        editstore();

    });
    //编辑门店
    function editstore(){
        //获取编辑的名称
        var mdname ="";
        //获取编辑的地址
        var address ="";
        //获取编辑的电话
        var phone = $('#bm_vphone').val();
        if(StringEmpty(mdname)&&StringEmpty(address)){
            var url = "<%=path%>/store/ajaxUpdateStore";
            $.post(url,{
                "access_token" : access_token,
                "cid" : cid,
                "uid" : uid,
                "id" : storeId,
                "name" : mdname,
                "address" : address,
                "phone" : phone,
            },function(data){

                if(data.error_code == "0"){
                    bmstore();
                    promptDialog("编辑成功！！");
                    $(".x_popup_editor,.issue_editor").hide();
                }else if(data.error_code == "4"){
                    promptDialog("该门店已存在，请勿重复编辑");
                }else{
                    promptDialog("编辑失败，请重试！!!");
                }
            });
        }else if(!StringEmpty(mdname) && !StringEmpty(address)){
            promptDialog("请输入门店信息！！！");
        }else if(!StringEmpty(mdname)){
            promptDialog("请输入门店名称！！！");
        }else if(!StringEmpty(address)){
            promptDialog("请输入门店地址！！！");
        }/* else if(!StringEmpty(phone)){
        	  showDialog("请输入手机号码！！！");
          } */
    }
    $('#bm_md_menmen').click(function(){
        $(".x_popup_editor,.issue_editor").hide();
    });

    //根据id查询门店
    function queryOne(){
        //  var storeId = $(this).attr("sid");
        var url = "<%=path%>/store/ajaxGetStoreDetail";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "storeId" : storeId,
        },function(data){

            if(data.status == 200){
                storexianHtml(data.data);
            }else if(data.error_code == 1){
            }

        });
    }
    //编辑门店时显示出来
    function storexianHtml(data){
        //门店名称
        $('#bm_vname').val(data.name);
        //门店地址
        $('#bm_vaddress').val(data.address);
        //手机号码
        $('#bm_vphone').val(data.phone);

    }
    //点击勾选用户bj5
    $(document).on('click','#bm_userlist img',function(){

        $('#bm_userlist img').attr("src","<%=path%>/images/marketing/s_check_no.png");
        var src = $(this).attr("src");
        if(src=="<%=path%>/images/marketing/s_check_no.png"){
            $(this).attr("src","<%=path%>/images/marketing/s_check.png");
        }else{
            $(this).attr("src","<%=path%>/images/marketing/s_check_no.png");
        }
    })

    //勾选
    $(document).on('click','#bm_cstore img',function(){
        
        //替换门店名称
        $("#micro_name").html($(this).attr("cname"));
       


  
        var src = $(this).attr("src");
        mdstore="";
        if(src=="<%=path%>/images/marketing/s_check_no.png"){
            $(this).attr("src","<%=path%>/images/marketing/s_check.png");
            mdname = $(this).attr("cname");
            var html = '';
        }else{
            $(this).attr("src","<%=path%>/images/marketing/s_check_no.png");
        }
        $('#bm_md_list').html(html);
    });

    //打叉移除选择的门店
    /* $(document).on('click','.delete_md_detail',function(){

    	$(this).remove();
    	$('#info11').hide();
    	$('#info1').hide();
    });  */

    $(document).on('click','.delete_md_detail img',function(){
        $('#bm_men_dian img').attr('src','<%=path%>/images/marketing/s_check_no.png');
        goumen = 1;
        $(this).remove();
        $('.delete_md_detail').remove();
        $('#info11').hide();
        $('#info1').hide();
    });


    //勾选后点击确定  用户确认user_ok  bj6
    var user_id;
    $('#user_ok').click(function(){
        $('.x_selectuser,.issue_selectuser').hide();
        //store_names.length=0;
        //store_ids.length=0;
        var name;
        $("#bm_userlist .x_CheckBox[src$='s_check.png']").each(
            function(i, d) {
                user_id = $(this).attr("id");
                name = $(this).attr("name");
            });
        //var html = name;
        /*for(var i in user_name){
            $('#micro_name').html(store_names[i]);
            $('#micro_address').html('<img src="<%=path%>/images/marketing/icon_address.png" />'+' '+store_address[i]+'</li>');
            $('#micro_phone').html('<img src="<%=path%>/images/marketing/icon_phone.png" />'+' '+store_phone[i]+'</li>');
            //暂存时获取数据
            html += '<li class="delete_md_detail" cid="'+store_names[i]+'" >'+store_names[i]+'<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
        }*/
        $('#bm_user_id').val(name);
    });
    //勾选后点击确定
    $('#bm_queque').click(function(){
        $('.x_popup_add,.issue_add').hide();
        store_names.length=0;
        store_ids.length=0;
        $("#bm_cstore .x_CheckBox[src$='s_check.png']").each(
            function(i, d) {
                var mdname = $(this).attr("cname");
              

                store_names[i]=mdname;
               
            });
        var html='';
        for(var i in store_names){
        	department+=store_names[i];
        	department+=",";
            $('#micro_name').html(store_names[i]);
            $('#micro_address').html('<img src="<%=path%>/images/marketing/icon_address.png" />'+' '+store_address[i]+'</li>');
            $('#micro_phone').html('<img src="<%=path%>/images/marketing/icon_phone.png" />'+' '+store_phone[i]+'</li>');
            //暂存时获取数据
            html += '<li class="delete_md_detail" cid="'+store_names[i]+'" >'+store_names[i]+'<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
        }
        $('#info11').show();
        $('#info1').show();
        $('#bm_md_list').html(html);

    });
    //删除门店
    //点击删除触发方法
    $(document).on('click','.deleted',function(){
        $('.s_popup_delect,.issue_delect').show();
        storeeId = $(this).attr("cid");
        /* deleteStore(); */
    });

    //点击取消隐藏
    $('#bm_shan_men').click(function(){
        $(".s_popup_delect,.issue_delect").hide();
    });

    //点击确定隐藏
    $('#bm_shan_que').click(function(){
        $(".s_popup_delect,.issue_delect").hide();
    });
    //打叉是隐藏
    $('#bm_md_cha').click(function(){
        $(".s_popup_delect,.issue_delect").hide();
    });

    //删除门店
    function deleteStore(){
        var url = "<%=path%>/store/ajaxDeleteStore";
        var lineId = '#line'+storeeId;
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "storeId" : storeeId,
        },function(data){

            if(data.error_code == "0"){
                bmstore();
                successDialog("删除成功！！！");
                $(lineId).remove();
            }else if(data.error_code == "2"){
                promptDialog("该门店已被选用，请勿删除");
            }else if(data.error_code == "1"){
                promptDialog("删除失败！！！");
            }else{
                promptDialog("系统出错");
            }
        });
    }


    //添加门店点击操作
    $('#bm_fque').click(function(){
        saveStore();

    });

    //添加门店操作
    function saveStore(){
        var cname = $('#bm_qming').val();
        var caddress = $('#bm_qaddress').val();
        var cphone = $('#bm_qphone').val();
        if(StringEmpty(cname)&&StringEmpty(caddress)){
            var url = "<%=path%>/store/ajaxCreateStore";
            $.post(url,{
                "access_token" : access_token,
                "cid" : cid,
                "uid" : uid,
                "name" : cname,
                "address" : caddress,
                "phone" : cphone,
            },function(data){

                if(data.error_code == "0"){
                    bmstore();
                    successDialog("添加门店成功！！！");
                }else if(data.error_code == "4"){
                    promptDialog("该门店已存在，请勿重复创建");
                }else{
                    promptDialog("添加门店失败！！！");
                }
            });
        }else if(!StringEmpty(cname) && !StringEmpty(caddress)){
            promptDialog("请输入门店信息！！！");
        }else if(!StringEmpty(cname)){
            promptDialog("请输入门店名称！！！");
        }else if(!StringEmpty(caddress)){
            promptDialog("请输入门店地址！！！");
        }/* else if(!StringEmpty(phone)){
          	  showDialog("请输入手机号码！！！");
            } */

    }

    //显示用户的方法bj3
    function userlistHtml(data){
        var html = "";
        var tag=false;
        for(var i=0;i<data.length;i++){
            html += '<tr id = "line'+data[i].id+'">'
            if(user_ids.length<1){
                html += '<td><div title="'+data[i].name+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><img id="'+data[i].id+'" src="<%=path%>/images/marketing/s_check_no.png" class="x_CheckBox" _id="27" name="' + data[i].name + '" phone="'+data[i].phone+'" departmentName="'+data[i].departmentName+'"/>&nbsp;&nbsp;' + data[i].name + '</div></td>';
            }else{
                for(var j=0;j<user_ids.length;j++){
                    if(data[i].id==user_ids[j]){
                        tag=true;
                    }
                }
                if(tag){
                    html += '<td><div title="'+data[i].name+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><img id="'+data[i].id+'" src="<%=path%>/images/marketing/s_check.png" class="x_CheckBox" _id="27" name="' + data[i].name + '" phone="'+data[i].phone+'" departmentName="'+data[i].departmentName+'"/>&nbsp;&nbsp;' + data[i].name + '</div></td>';
                }else{
                    html += '<td><div title="'+data[i].name+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><img id="'+data[i].id+'" src="<%=path%>/images/marketing/s_check_no.png" class="x_CheckBox" _id="27" name="' + data[i].name + '" phone="'+data[i].phone+'" departmentName="'+data[i].departmentName+'"/>&nbsp;&nbsp;' + data[i].name + '</div></td>';
                }
            }
            html += '<td><div title="'+data[i].phone+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">' + data[i].phone + '</div></td>';
            html += '<td><div title="'+data[i].departmentName+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">' + data[i].departmentName + '</div></td>';
            html += '<td><div title="'+data[i].stores+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">' + data[i].stores + '</div></td>';
            tag=false;

        }
        $('#bm_userlist').html(html);
    }
    //显示门店方法
    function storeHtml(data){
        var html = "";
        var tag=false;
        for(var i=0;i<data.length;i++){
            html += '<tr id = "line'+data[i].id+'">'
            if(store_ids.length<1){
                html += '<td><div title="'+data[i].name+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><img id="'+data[i].id+'" src="<%=path%>/images/marketing/s_check_no.png" class="x_CheckBox" _id="27" cname="' + data[i].name + '" bmstore_phone="'+data[i].phone+'" bmstore_address="'+data[i].address+'"/>&nbsp;&nbsp;' + data[i].name + '</div></td>';
            }else{
                for(var j=0;j<store_ids.length;j++){
                    if(data[i].id==store_ids[j]){
                        tag=true;
                    }
                }
                if(tag){
                    html += '<td><div title="'+data[i].name+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><img id="'+data[i].id+'" src="<%=path%>/images/marketing/s_check.png" class="x_CheckBox" _id="27" cname="' + data[i].name + '" bmstore_phone="'+data[i].phone+'" bmstore_address="'+data[i].address+'"/>&nbsp;&nbsp;' + data[i].name + '</div></td>';
                }else{
                    html += '<td><div title="'+data[i].name+'" style="width:14em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><img id="'+data[i].id+'" src="<%=path%>/images/marketing/s_check_no.png" class="x_CheckBox" _id="27" cname="' + data[i].name + '" bmstore_phone="'+data[i].phone+'" bmstore_address="'+data[i].address+'"/>&nbsp;&nbsp;' + data[i].name + '</div></td>';
                }
            }
     
            tag=false;

        }
        $('#bm_cstore').html(html);
    }

    // 	    $(function(){
    // 	    	inputlimited("#bm_qming",23);
    // 	    	inputlimited("#bm_qaddress",25);
    // 	    	inputlimited("#bm_vname",23);
    // 	    	inputlimited("#bm_vaddress",25);
    // 	    });
    //二次点击暂存时进行的修改操作
    function cardHtml(data){

        $('#cc_name').text(data.companyName);
        $('#head_pic').attr("src",data.headPicture);
        $('#cc_nname').text(data.name);
        $('#cc_job').text(data.job);

        var zuoyouhtml = '<img src="<%=path%>/images/marketing/icon_plume.png"/>&nbsp;&nbsp;';
        $('#cc_zuoyou').html(zuoyouhtml+data.userdefined);

        var phonehtml = '<img src="<%=path%>/images/marketing/icon11.png" />&nbsp;&nbsp;';
        $('#cc_phone').html(phonehtml+data.mobile);

        var zuojihtml = '<img src="<%=path%>/images/marketing/icon22.png" />&nbsp;&nbsp;';
        $('#cc_zuoji').html(zuojihtml+data.zuoMobile);

        var mailhtml = '<img src="<%=path%>/images/marketing/icon33.png" />&nbsp;&nbsp;';
        $('#cc_mail').html(mailhtml+data.mail);

        var wxhtml = '<img src="<%=path%>/images/marketing/icon55.png" />&nbsp;&nbsp;';
        $('#cc_weixin').html(wxhtml+data.weixin);

        var wbhtml = '<img src="<%=path%>/images/marketing/icon66.png" />&nbsp;&nbsp;';
        $('#cc_weibo').html(wbhtml+data.weibo);

        var qqhtml = '<img src="<%=path%>/images/marketing/icon44.png" />&nbsp;&nbsp;';
        $('#cc_qq').html(qqhtml+data.qq);


        if(!StringEmpty(data.userdefined)){
            $('#cc_zuoyou').html('');
        }
        if(!StringEmpty(data.zuoMobile)){
            $('#cc_zuoji').html('');
        }
        if(!StringEmpty(data.mail)){
            $('#cc_mail').html('');
        }
        if(!StringEmpty(data.weixin)){
            $('#cc_weixin').html('');
        }
        if(!StringEmpty(data.weibo)){
            $('#cc_weibo').html('');
        }
        if(!StringEmpty(data.qq)){
            $('#cc_qq').html('');
        }
    }

  <%--   //微门户
    function weiMicroHtml(data){
        $('#micro_name').html(data.name);
        $('#micro_pic').attr('src',data.pic);
        if(StringEmpty(data.name))
            $('#bm_md_list').html('<li class="delete_md_detail" cid="'+data.name+'" >'+data.name+'<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li>');
        var tagHtml='';
        var tag=data.tag.split(",");
        for(var i in tag){
            tagHtml+='<li>'+tag[i]+'</li>';
        }
        $('#micro_tag').html(tagHtml);
        //$('#micro_score').append(data.score);
        $('#business_hours').html(data.business_hours);
        var addressHtml = '';
        var kongge = '  ';
        $('#micro_address').html('<img src="<%=path%>/images/marketing/icon_address.png" />'+kongge+data.address+'</li>');
        $('#micro_phone').html('<img src="<%=path%>/images/marketing/icon_phone.png" />'+kongge+data.phone+'</li>');

    }
 --%>
    //把填的信息填充上
    function cardyHtml(data){
        $("#focusedInput").val(data.companyName);
        //头像
        $('#card_image').attr("src",data.headPicture);
        $('#bm_cname').val(data.name);
        $('#bm_cjob').val(data.job);
        $('#bm_cmoblie').val(data.mobile);
        $('#bm_czuoji').val(data.zuoMobile);
        $('#bm_cmail').val(data.mail);
        $('#bm_cweixin').val(data.weixin);
        $('#bm_cweibo').val(data.weibo);
        $('#bm_cqq').val(data.qq);
        $('#bm_cziding').val(data.userdefined);
        //二维码
        /* $('#qrcode_image').attr("src",data.erCode); */
        makeCode();
    }
    //从其他页面进入时执行该方法   查询你该名片的详细信息（我的名片里的所有信息）
    var userid_edit;
    function queryCard(cardId){
        var url = "<%=path%>/businessCard/querycard";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "id" :cardId,
        },function(data){
        	
            //bj11   获取用户id用于回显用户姓名
            userid_edit = data.data.userId
            //点击编辑名片回显员工姓名 bj9
            $(function(){
                var url = "<%=path%>/api/account/getUserNameByUserId";
                $.post(url,{
                    "userId" : userid_edit
                },function(msg){
                    if(data.error_code==0){
                        $("#bm_user_id").val(msg.data);
                    }
                })
            })
            if(data.error_code==0){
                save_tag=true;
                
                goumen = data.data.bak1;
                gouye = data.data.bak2;
                goutui = data.data.bak3;
                if(goumen == "1"){
                    var qugou = $('#bm_men_dian img').attr('src','<%=path%>/images/marketing/s_check_no.png');
//     				microPortal();
                }
                if(gouye == "1"){
                    var qugouye = $('#bm_ye_wu_gou img').attr('src','<%=path%>/images/marketing/s_check_no.png');
                    $("#info2").hide();
                }
                if(goutui == "1"){
                    var qugoutui = $('#bm_tui_tui img').attr('src','<%=path%>/images/marketing/s_check_no.png');
                    $("#info3").hide();
                }
                console.log("goumen----------->"+goumen);
                if(goumen == "0"){
                    console.log("获取微门户----》");
                    microPortal();
                    $('#info11').show();
                    $('#info1').show();
                }else{
                    $('#info11').hide();
                    $('#info1').hide();
                }

                cardHtml(data.data);
                cardyHtml(data.data);
                companyName = data.data.companyName;
                mpname = data.data.name;
                job= data.data.job;
                mobile= data.data.mobile;
                cardStore();
                yewuList(cardId);

            }else{
                //showDialog("预览出错！！！");
            }

        });

    }

    //获取活动门店信息（页面中我的名片下面的信息）
    function cardStore(){
        var url = "<%=path%>/api/card_store/query";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "card_id" : cardId,
        },function(data){
            if(data.error_code == "0"){
                var stores=data.data;
                var html='';
                for(var i in stores){
                    store_ids[i]=stores[i].id;
                    store_names[i]=stores[i].name;
                    html += '<li class="delete_md_detail" cid="'+stores[i].name+'" >'+stores[i].name+'<img src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
                }
                $('#li_address').text("地址:"+stores[0].address);
                $('#store_num').text("全部"+store_ids.length+"家分店");
                //修复门店名称在灰框中显示与数据不匹配的bug
                //$('#bm_md_list').html(html);
            }else{
                //showDialog(data.message);
            }
        });
    }


    //获取部门
    function microPortal(){
    	console.log("查询部门");
        var url = "<%=path%>/api/microportal/detail";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid ,
            //"store_id" : store_id
        },function(data){
            //alert(data.data.name);
            if(data.error_code == "0"){
                
               /*  weiMicroHtml(data.data); */
            }else{
                //	showDialog(data.message);
                //	showDialog("无微门户信息");
               // $('#info11').hide();
               // $('#info1').hide();
            }
        });
    }

    //修改微门户信息
    function updateMicro(){
        var weiname = $('#micro_name').text();
        var weiaddress = $('#micro_address').text();
        var weiphone = $('#micro_phone').text();


        console.log("修改weiname:1111"+weiname);
        console.log("修改weiaddress:1111"+weiaddress);
        console.log("修改weiphone:1111"+weiphone);

        var url = "<%=path%>/api/microportal/create";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid ,
            "address" : weiaddress,
            "phone" : weiphone,
            "store_name" :weiname,
            "store_id" : store_ids
        },function(data){

            if(data.error_code == "0"&&data.data!=null){
             /*    weiMicroHtml(data.data)
 */            }
        });
    }

    //保存用戶选择的门店
    function addStore(){
        var storeIds=store_ids.join(",");
        var url = "<%=path%>/api/card_store/insert";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "card_id" : cardId,
            "store_ids" : storeIds,
        },function(data){

            if(data.error_code == "0"){
            }else{
                //showDialog(data.message);
            }
        });
    }
    var flag=false;
    function uploadPic() {
        $("#upload_pic").submit(function (event) {
            if(flag){
                return ;
            }
            flag=true;
            $("#upload_pic").ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/api/uploadfile/file",
                data:{"typename":"filepath"},
                success: function (data1) {
                    
                    head_pic=data1.realSavePath;
                    if(StringEmpty(head_pic)){
                        var tutu = $('#card_image').attr('src',data1.realSavePath);
                        var pian = $('#head_pic').attr('src',data1.realSavePath);
                    }

                },
                error: function (msg) {
                    promptDialog("文件上传失败");
                }
            });
            return false;
        });
        flag=false;
        $("#upload_pic").submit();
    }

    //上传h5活动图片  bj001
    function fileloadon() {
        var flag=false;
        $("#share_image").submit(function () {
            if(flag){
                return ;
            }
            flag=true;
            $("#share_image").ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath}/api/uploadfile/file",
                data:{"typename":"filepath"},
                success: function (data1) {
                    share_pic=data1.realSavePath;
                    $("#share_pic").attr('src',data1.share_pic);
                    $("#ep_pic").prop('src',data1.share_pic);
                },
                error: function (msg) {
                    errorDialog("文件上传失败");
                }
            });
            return false;
        });
        $("#share_image").submit();
    }
    //判断字符串是否为空
    function StringEmpty(content) {
        if (content == undefined || content == "" || content == null) {
            return false;
        } else {
            return true;
        }
    }
    //判断是否为手机号码
    function telPhone(cphone){
        var reg =/^1(3|4|5|7|8)\d{9}$/;//正则表达式
        var result = reg.test(cphone);	//匹配
        if(!result){
            return false;
        }else{
            return true;
        }
    }
    //判断邮箱
    function memail(eemail){
        var regEmail = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
        var result = regEmail.test(eemail);
        if(!result){
            return false;
        }else{
            return true;
        }
    }
    //判断座机
    function zuoj(zuojii){
        var regZuoj = /^(\d{2,4}-?)?\d{7,8}$/;
        var result = regZuoj.test(zuojii);
        if(!result){
            return false;
        }else{
            return true;
        }
    }
    //判断qq
    function mqq(tqq){
        var  regqq= /^\d{5,10}$/;
        var result = regqq.test(tqq);
        if(!result){
            return false;
        }else{
            return true;
        }
    }
    /*    //判断座机
       function zuoji(zuo){
           var regzuo = /^0\d{2,3}-[1-9]\d{6,7}$/;
           var result = regzuo.test(zuo);	//匹配
           if(!result){
               return false;
           }else{
               return true;
           }
       } */
    //  js获取url中的参数的方法
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)
            return unescape(r[2]);
        return null;
    }


    function showDialog(title){
        $('#dialog_title').html('<img src="<%=path%>/images/marketing/s_tick.png"/>'+title+'');
        $('.s_popup_delect2,.s_consum').show().delay(2000).fadeOut();
    }


    var startIndex = 0;
    var pageSize = 5;
    var currentPage = 1;
    var pageCount = 0;
    var listIndex = 0;
    var activityJsonArr = [];	//活动jsonArray

    var status="";
    var access_token=$.cookie('access_token');
    var cid=$.cookie('cid');
    var uid=$.cookie('uid');
    
    var aid;

    //推荐活动
    var sysIds;
    //业务活动
    var definedIds;

    var type;


    //var yewuIds;
    //var tuijaiIds;

    //获取用系统模板创建的活动列表(推荐)
    function activityList(){
        if (listIndex != 3){
            listIndex =0;
        }
        listIndex = 3;
        var url = path+ "/activity/ajaxActivityPageList";
        $.post(url, {
            "startIndex" : startIndex,
            "pageSize" : pageSize,
            "cid" : cid,
            "uid" : uid,
            "access_token" : access_token,
			"status":1,
			"distinction":0,
        }, function(data) {
            var msg;
            msg=data.data;
            
            activityhtml(msg);
            page(data.totalCount);

        });
    }


    //获取用自定义模板创建的活动列表（业务）
    function activitymu(){
        //console.debug("业务列表：");
        //console.debug(yewuActivity);
        if(listIndex != 2){
            listIndex = 0;
        }
        listIndex = 2;
        var url = path + "/activity/ajaxActivityPageList";
        $.post(url, {
            "startIndex" : startIndex,
            "pageSize" : pageSize,
            "cid" : cid,
            "uid" : uid,
            "access_token" : access_token,
			"status":1,
			"distinction":1,
        }, function(data) {
            var msg;
            msg=data.data;
            
            activityhtml2(msg);
            console.log("-------数据大小------>"+data.totalCount);
            page(data.totalCount);

        });
    }


    //显示活动列表（推荐）
    function activityhtml(data){
        //console.debug("推荐列表：");
        //console.debug(tuijainActivity);
        if(data == undefined){
            return	;
        }
        var html="";
        for(var i=0;i<data.length;i++){
            var result=data[i];
            html += '<li cname="'+result.name+'">';
            html += '<span style=display:none  ccid="'+result.id+'"  browseren="'+result.browse_num+'" id="'+result.id+'" tuid="'+result.id+'"  tuipic="'+(result.share_pic==''?result.head_pic:result.share_pic)+'" tuiname="'+result.name+'" tend_t="'+result.end_time+'" canren="'+result.receive_coupon_num+'" tuiwebu = "'+result.web_url+'"></span>';
            html += '<div class="chance">';
            html += '<dl class="k_img_box">';
            html += '<dt><img style="width:64px; height:104px;" src="'+(result.share_pic==''?result.head_pic:result.share_pic)+'"></dt>';
            html += '<dd>';
            html += '<h5 class="bm_jiac">';
            html += '<a href="javascript:;" turl="'+result.web_url+'" class="bm_huotui">'+result.name+'</a></h5>'
            html += '<p>领取数/总数:' + result.receive_coupon_num + '</p>';
            if(StringEmpty(result.end_time)){
                html += '<p>有效期至' + (result.end_time=='undefined' ? "":result.end_time) + '</p>';
            }else{
                html += '<p style="display:none">有效期至' + (result.end_time=='undefined' ? "":result.end_time) + '</p>';
            }
            html += '</dd>';
            html += '</dl>';
            html += '</div>';
            html += '<div class="tags">';
            html += '<span>' + result.tag_defined + '</span>';
            html += '</div>';
            html += '<div class="tags main">';
            html += '<em style="margin-top: 65px; float: right;">转化率<b>'+' '+result.ratio+'%'+'</b></em>';
            html += '</div>';
            html += '<div class="tags nor">';
            html += '<span>'+ (result.status == 1 ? "正常" : "停用") +'</span>';
            html += '</div>';
            html += '</li>';
        }
        $('#activity_list').html(html);
        var lis = $('#activity_list').children('li');
        $(lis).each(function(){
            var ca = $(this).attr('cname');
            for(var  i  in  activityJsonArr){
                var result = activityJsonArr[i];
                if(result.tuiname == ca){
                    $(this).attr('class','on');
                }
            }
            for(var j in tuijainActivity){
                var nMap = tuijainActivity[j];
                if(nMap.name == ca){
                    $(this).attr('class','on');
                }
            }
        });
    }

    //点击url时，新建一个页面（推荐）
    $(document).on("click",".bm_huotui",function(){
        var urlt=$(this).attr("turl");
        window.open(urlt);

    });
    var tuijainActivity;
    var yewuActivity;

    //显示活动列表（业务）
    function activityhtml2(data){
        if(data == undefined){
            return	;
        }
        var html="";
        for(var i=0;i<data.length;i++){
            var result=data[i];
            html += '<li cname="'+result.name+'">';
            html += '<span style=display:none  ccid="'+result.id+'" id="'+result.id+'" riqi="'+result.end_time+'" yezhuan="'+result.ratio+'" yeling="'+result.receive_coupon_num+'" huoid="'+result.id+'" yname="'+result.name+'" cheadpic="'+(result.share_pic==''?result.head_pic:result.share_pic)+'" ccent="'+result.content+'"  webu = "'+result.web_url+'" ></span>';
            html += '<div class="chance">';
            html += '<dl class="k_img_box">';
            html += '<dt><img style="width:64px; height:104px;" src="'+(result.share_pic==''?result.head_pic:result.share_pic)+'"></dt>';
            html += '<dd>';
            html += '<h5 class="bm_jiac">';
            html += '<a href="javascript:;" turl="'+result.web_url+'" class="bm_huotui">'+result.name+'</a></h5>'
            html += '<p>领取数/总数:' + result.receive_coupon_num + '</p>';
            if(StringEmpty(result.end_time)){
                html += '<p>有效期至' + (result.end_time=='undefined' ? "":result.end_time) + '</p>';
            }else{
                html += '<p style="display:none">有效期至' + (result.end_time=='undefined' ? "":result.end_time) + '</p>';
            }
            html += '</dd>';
            html += '</dl>';
            html += '</div>';
            html += '<div class="tags">';
            html += '<span>' + result.tag_defined + '</span>';
            html += '</div>';
            html += '<div class="tags main">';
            html += '<em style="margin-top: 65px; float: right;">转化率<b>'+' '+result.ratio+'%'+'</b></em>';
            html += '</div>';
            html += '<div class="tags nor">';
            html += '<span>'+ (result.status == 1 ? "正常" : "停用") +'</span>';
            html += '</div>';
            html += '</li>';

        }
        $('#activity_list').html(html);
        var lis = $('#activity_list').children('li');
        $(lis).each(function(){
            var ca = $(this).attr('cname');
            /*for(var  i  in  activityJsonArr){
                var result = activityJsonArr[i];
               if(result.yname == ca){
                   $(this).attr('class','on');
               }
            }*/
            for(var j in yewuActivity){
                var ywName = yewuActivity[j];
                if(ywName.name == ca){
                    $(this).attr('class','on');
                }
            }
        });
    }

    //点击url时，新建一个页面（业务）
    $(document).on('click','.bm_huoye',function(){
        var urly = $(this).attr("yurl");
        window.open(urly);
    });

    //根据多个id查询活动
    <%-- function activiId(ids){
        var url = "<%=path%>/activity/activiting";
        $.post(url,{
            "cid" : cid,
            "uid" : uid,
            "access_token" : access_token,
            "id" : id
        },function(data){

        });
    } --%>


    $(".m_xpages select").change(function(){
        pageSize = Number($(this).val());
        if(listIndex == 1){
            bmstore();
        }else if(listIndex == 2){
            activitymu();
        }else if(listIndex == 3){
            activityList();
        }else if(listIndex == 4){
            userlist();
        }

    });

    $(".m_xpages a.prev").click(function(){
        $('.next').html('<font color="black">下一页</font>');
        if(currentPage > 1){
            currentPage--;
            startIndex -= pageSize;
            if(currentPage == 1){
                $('.prev').html('<font color="#E0E0E0">上一页</font>');
            }

            if(listIndex == 1){
                bmstore();
            }else if(listIndex == 2){
                activitymu();
            }else if(listIndex == 3){
                activityList();
            }else if(listIndex == 4){
                userlist();
            }
        }

    });

    $(".m_xpages a.next").click(function(){
        $('.prev').html('<font color="black">上一页</font>');
        if(currentPage < pageCount){
            currentPage++;
            startIndex += pageSize;
            if(currentPage == pageCount){
                $('.next').html('<font color="#E0E0E0">下一页</font>');
            }
            if(listIndex == 1){
                bmstore();
            }else if(listIndex == 2){
                activitymu();
            }else if(listIndex == 3){
                activityList();
            }else if(listIndex == 4){
                userlist();
            }
        }
    });

    $(".m_xpages :text").keyup(function(e){
        if(e.keyCode==13){
            var pageGo = $(this).val();
            if(/^[0-9]+$/.test(pageGo)){
                pageGo = Number(pageGo);
                if(pageGo<1 || pageGo>pageCount){
                    showDialog('请输入合法页数');
                }else if(pageGo != currentPage){
                    startIndex = (pageGo -1) * pageSize ;
                    if(listIndex == 1){
                        bmstore();
                    }else if(listIndex == 2){
                        activitymu();
                    }else if(listIndex == 3){
                        activityList();
                    }else if(listIndex == 4){
                        userlist();
                    }

                }
            }else{
                showDialog('请输入合法页数');
            }
        }
    });
    function page(totalCount) {
        pageCount = totalCount / pageSize;
        if (totalCount % pageSize > 0)
            pageCount++;
        pageCount = parseInt(pageCount);
        currentPage = startIndex / pageSize + 1;
        currentPage = parseInt(currentPage);

        var isPageDisable = "";
        if (currentPage == 1) {
            isPageDisable = "pageDisable";
        } else {
            isPageDisable = "";
        }
        var prev = '<a href="javascript:;" class="prev '+isPageDisable+'">上一页</a>';
        $(".prev").addClass(isPageDisable);

        if (currentPage == pageCount) {
            isPageDisable = "pageDisable";
        } else {
            isPageDisable = "";
        }
        var next = '<a href="javascript:;" class="next '+isPageDisable+'">下一页</a>';
        $(".next").addClass(isPageDisable);
        //$(".m_xpages>.mian>span:eq(1)").text('共' + totalCount + '条');
        //$(".m_xpages>.mian>span:eq(2)").text(currentPage + '/' + pageCount + '页');

        $(".bm_tiao").text('共' + totalCount + '条');
        $(".bm_ye").text(currentPage + '/' + pageCount + '页');
    }

    //选择列表（业务介绍）bj22
    $('.bm_yewu').click(function(){
        $('.prev').html('<font color="#E0E0E0">上一页</font>');
        $('.next').html('<font color="black">下一页</font>');

        startIndex = 0;
        pageSize = 5;
        currentPage = 1;
        pageCount = 0;
        listIndex = 0;
        $('#bm_ye_wu_gou img').attr('src','<%=path%>/images/marketing/s_check.png');
        $('#info2').show();
        gouye = 0;
        <%-- $('.title').html('<i class="J_xsutup"><img id="bm_ca1" src="<%=path%>/images/close.png" /></i>选择图文模板');
        $('.caption').html('<span style="width:50%;">图文模板概览</span><span style="width:15%;">统计值</span><span style="width:35%;">状态</span>'); --%>
        activitymu();
        $('#activity_list').html('');

        $('.m_xpopups').show();
        $('.m_xpropell').show();
        $('.J_xactivity').addClass('show');
        $('#bm_wanwa').attr('class','bm_ye_wu');
    });
    //选择列表（我推荐）
    $('.bm_wotuijian').click(function(){
        $('.prev').html('<font color="#E0E0E0">上一页</font>');
        $('.next').html('<font color="black">下一页</font>');

        startIndex = 0;
        pageSize = 5;
        currentPage = 1;
        pageCount = 0;
        listIndex = 0;
        $('#bm_tui_tui img').attr('src','<%=path%>/images/marketing/s_check.png');
        goutui = 0;
        $('#info3').show();
        $('#activity_list').html('');
        <%-- $('.title').html('<i class="J_xsutup"><img id="bm_ca1" src="<%=path%>/images/close.png" /></i>选择推送活动');
        $('.caption').html('<span>活动概览</span><span>活动标签</span><span>统计值</span><span>状态</span>'); --%>
        activityList();


        $('.J_xactivity').addClass('show');
        $('.m_xpopups').show();
        $('.m_xpropell').show();
        $('#bm_wanwa').attr('class','bm_tui_jian');

    });
    //打叉隐藏
    $(document).on('click','#bm_ca1',function(){
        $('.J_xcontact , .J_xactivity').hide();
    });


    //点击取消隐藏
    $('.white').click(function(){
        $('.m_xpopups').hide();
        $('.m_xpropell').hide();
        $('.J_xcontact , .J_xactivity').removeClass('show');
    });

    //添加删除class
    $(function(){
        $(document).on("click",".J_xactivity ul>li",function(){
            console.debug(activityJsonArr);
            if($(this).hasClass("on")||$(this).find("span").hasClass("me")){
                //alert("取消");
                $(this).removeClass("on");
                $(this).find("span").removeClass("me");

                for (var i = 0; i < activityJsonArr.length; i++) {
                    var json = activityJsonArr[i];
                    if($(this).attr("ccid") == json.ccid){
                        activityJsonArr.splice(i,1);
                        console.debug("取消");
                        console.debug(activityJsonArr);
                        break;
                    }
                }
                /*for (var i = 0; i < yewuActivity.length; i++) {
                    var json = yewuActivity[i];
                    if($(this).attr("ccid") == json.ccid){
                        yewuActivity.splice(i,1);
                        console.debug("取消");
                        console.debug(yewuActivity);
                        break;
                    }
                }*/
            }else{
                //$("#micro_phone").html($(this).attr("bmstore_phone"));
                //alert("选中");
                $(this).addClass("on");
                $(this).find("span").addClass("me");
                var json = {'huoid':$(this).find("span").attr("huoid"),'yname':$(this).find("span").attr("yname"),
                    'cheadpic':$(this).find("span").attr("cheadpic"),'ccent':$(this).find("span").attr("ccent"),
                    'webu':$(this).find("span").attr("webu"),'tuid':$(this).find("span").attr("tuid"),
                    'tuiname':$(this).find("span").attr("tuiname"),'tuiwebu':$(this).find("span").attr("tuiwebu"),
                    'tuipic':$(this).find("span").attr("tuipic"),'tend_t':$(this).find("span").attr("tend_t"),
                    'canren':$(this).find("span").attr("canren"),'browseren':$(this).find("span").attr("browseren")};
                activityJsonArr.push(json);
                //yewuActivity.push(json);
                console.debug("选中");
                console.debug(activityJsonArr);
            }
        });
    });

    //选择活动后点击完成
    $(document).on('click','#bm_wanwa',function(){
        var pd = $(this).attr('class');
        var html_='';
        var str='';
        var tuiHtml='';
        var htm='';
        var fantuiHtml='';
        //获取选取的活动,点击完成后显示出来
        //console.debug(activityJsonArr);
        for(var i=0;i<activityJsonArr.length;i++){
            var json = activityJsonArr[i];
            //两边显示(业务)
            if(pd == "bm_ye_wu"){
                if(json.huoid!=undefined && json.yname!=undefined && json.cheadpic!==undefined && json.webu!==undefined && json.ccent!=undefined){
                    html_ += '<li id="yeshan'+json.huoid+'" class="deleteye" yid="'+json.huoid+'">'+json.yname+'<img src="<%=path%>/images/marketing/close.png" class="x_lista" id="yeshan'+json.huoid+'" yid="'+json.huoid+'"></li>';

                    str+='<div style="background: #fff;border-bottom: 11px solid #F7F7F7;margin-bottom:10px;height: 163px" id="yechu'+json.huoid+'"><dl class="fix"><div style="border-bottom: 1px solid #eee;height: 105px;"><dt><img style="width:72px; height:72px;" src="'+json.cheadpic+'" /></dt>';
                    str+='<dd id="bm_ziding"><p>'+json.yname+'</p>';
                    str+='<i>'+json.ccent+'</i></dd></div></dl></div>';

                    //解决了在点击完成后业务框只显示选中的业务，之前的业务无法显示
                    $('#bm_yewuxian').html(html_+html);
                    $('#bm_yewushow').html(str+htmlye);
                }
            }

            //两边显示（推荐）
            if(pd == "bm_tui_jian"){

                if(json.tuid!=undefined && json.tuiname!=undefined && json.tuipic!=undefined && json.tuiwebu!=undefined && json.tend_t!=undefined
                    && json.canren!=undefined && json.browseren!=undefined){
                    tuiHtml += '<li id="shan'+json.tuid+'" class="deletehuo" tid="'+json.tuid+'">'+json.tuiname+'<img src="<%=path%>/images/marketing/close.png" class="x_lista" id="shan'+json.tuid+'" tid="'+json.tuid+'"></li>';
                    htm += '<div class="k_content" id="chu'+json.tuid+'"><dl class="fix"><dt><img style="width:72px; height:72px;" src="'+json.tuipic+'"/></dt>' ;
                    htm += '<dd><p>'+json.tuiname+'<i>进行中</i></p>';

                    if(StringEmpty(json.tend_t)){
                        htm += '<em style="margin-top:4px;">有效期至：'+json.tend_t+'</em></dd></dl>';
                    }else{
                        htm += '<em style="margin-top:4px;"></em></dd></dl>';
                    }
                    //	htm += '<em>有效期至：'+json.tend_t+'</em></dd> </dl>';
                    htm += '<ol class="fix">';
                    htm += '<div><li class="s_partake" style="display:none">'+json.canren+'人参与</li>';
                    htm += '<li class="s_like" style="display:none"><img class="s_dianzan_img" src="<%=path%>/images/marketing/dianzan.png" _id="1" />'+json.browseren+'</li></div></ol></div>';

                    console.log("1234556778---------->"+json.tuiname);
                    console.debug(tuiHtml+htmltui);
                    console.debug(htm+htmljian);
                    $('#bm_tuijan').html(tuiHtml+htmltui);
                    $('#bm_xianshi').html(htm+htmljian);
                }
            }
        }

    });


    //我推荐列表点击叉移除
    $(document).on('click','.deletehuo img',function(){
        var tuid = $(this).attr("tid");
        var lineid = '#shan' + tuid;
        var shanchu = '#chu' +tuid;
        $(lineid).remove();
        $(shanchu).remove();
    });
    //业务里外表点击叉移除
    $(document).on('click','.deleteye img',function(){
        var syuid = $(this).attr("yid");
        var lineid = '#yeshan' + syuid;
        var shanchu = '#yechu' +syuid;
        $(lineid).remove();
        $(shanchu).remove();
    });

    function childFinish(){
        /* for( i in activityJsonArr){
            var json = activityJsonArr[i];

        } */
        /* $('.import').val("");
        var text = "";
        $(".J_xactivity ul>li[class='on']").each(function(i,d){
            text += $(this).find('div>dl>dd>h5>a').text()+"\r";
        });
        $('.import').val(text); */
        $('.m_xpopups').hide();
        $('.m_xpropell').hide();
        $('.J_xcontact , .J_xactivity').removeClass('show');
    }

    //保存业务活动
    function saveYeActivity(cardId){
        /*  var yeIds = new Array();
            var definedIds;
            $('.deleteye').each(function(j,d){
               var yyid = $(this).attr('yid');
             yeIds[j]=yyid;
            });
            definedIds = yeIds.join(",");
           console.log("yeIds---------------:"+yeIds);  */
        var url = "<%=path%>/businessCard/insertCardActivity";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "card_id" : cardId,
            "ids" : definedIds,
            "type" : 1
        },function(data){

            if(data.status == 200){
                save_tag=true;
            }
        });
    }


    //保存推荐活动
    function saveTuiActivity(cardId){
        /*  var tuiIds = new Array();
            var sysIds;
             $('.deletehuo').each(function(j,d){
               var ttuid = $(this).attr('tid');
            tuiIds[j]=ttuid;
            });
       sysIds=tuiIds.join(",");
       console.log("tuiIds---------------:"+tuiIds);  */
        var url = "<%=path%>/businessCard/insertCardActivity";
        $.post(url,{
            "access_token" : access_token,
            "cid" : cid,
            "uid" : uid,
            "card_id" : cardId,
            "ids" : sysIds,
            "type" : 2
        },function(data){

            if(data.status == 200){
                save_tag=true;
                console.log("进入保存推荐活动方法:"+save_xia);

                if(save_xia==true){
                    window.location.href = "<%=path%>/api/bm/ui/cardPreview?card_id="+cardId;
                }else{
                    successDialog("暂存成功");
                    addStore();
                }
            }
        });
    }


    var yeuTag=false;
    var tuiTag=false;
    //点击重新编辑修改选择的业务
    function yeupdateActivity(cardId) {
        //alert("111--->"+definedIds);
        /* var yid = new Array();
           var yewuIds;
           $('.deleteye').each(function(j,d){
              var yyid = $(this).attr('yid');
               yid[j]=yyid;
           });
          yewuIds = yid.join(",");   */
        var yewuLength = definedIds.split(',').length;
        if (yewuLength <= 5) {
            yeuTag = false;
            var url = "<%=path%>/businessCard/ajaxUpdateCardActivity";
            $.post(url, {
                "access_token": access_token,
                "cid": cid,
                "uid": uid,
                "cardId": cardId,
                "ids": definedIds,
                "type": 1,
            }, function (data) {

                if (data.status == 200) {
                    save_tag = true;
                    if (save_xia == true) {
                        yeuTag = true;
                        intentPreview();
                    } else {
                        successDialog("修改信息成功");
                        microPortal();
                    }
                }
            });
        }else {
            promptDialog("所选业务不能超过5个，请您重新选择");
        }
    }
    //点击重新编辑修改推荐活动
    function tuiupdateActivity(cardId){
        // alert("222--->"+sysIds);
        /* var tuid = new Array();
              var tuijaiIds;
              $('.deletehuo').each(function(j,d){
                var ttuid = $(this).attr('tid');
                 tuid[j]=ttuid;
             });
             tuijaiIds = tuid.join(",");  */
        var tuijianLength = sysIds.split(',').length;
        if (tuijianLength <= 5) {
            tuiTag=false;
            var url = "<%=path%>/businessCard/ajaxUpdateCardActivity";
            $.post(url, {
                "access_token": access_token,
                "cid": cid,
                "uid": uid,
                "cardId": cardId,
                "ids": definedIds,
                "type": 2,
            }, function (data) {

                if(data.status == 200){
                    save_tag=true;
                    if(save_xia==true){
                        tuiTag=true;
                        intentPreview();
                    }else{
                        successDialog("修改信息成功");
                        microPortal();
                    }
                }

            });
        }else {
            promptDialog("所选推荐不能超过5个，请您重新选择");
        }
    }

    function intentPreview(){
        if(tuiTag && yeuTag)
            window.location.href = "<%=path%>/api/bm/ui/cardPreview?card_id="+cardId;
    }


    var html = '';
    var htmlye = '';

    var htmltui = '';
    var htmljian = '';
    //从其他页面进入时获取当前名片业务列表

    function yewuList(cardId){
    	var url = "<%=path%>/businessCard/queryActivityList";
	   	$.post(url,{
	   		 "access_token" : access_token,
			 "cid" : cid,
		     "cid" : cid,
			 "cardId" : cardId,
	   	},function(data){
            if(data.error_code == "0"){
                activityJsonArr = data.operationData;
                //业务
                yewuActivity = data.operationData;
                //推荐
                tuijainActivity = data.activityData;


                for(var i in yewuActivity){
                    var act_idd = yewuActivity[i].id;
                    var act_yename = yewuActivity[i].name;
                    var act_head_pic = yewuActivity[i].head_pic;
                    var act_concent = yewuActivity[i].content;
                    var act_web_yeurl = yewuActivity[i].web_url;
                    var act_share_url = yewuActivity[i].share_pic;

                    html += '<li id="yeshan'+act_idd+'" class="deleteye" yid="'+act_idd+'">'+act_yename+'<img src="<%=path%>/images/marketing/close.png" class="x_lista" id="yeshan'+act_idd+'" yid="'+act_idd+'"></li>';

                    if(StringEmpty(act_share_url)){
                        htmlye += '<div style="background: #fff;border-bottom: 11px solid #F7F7F7;margin-bottom:10px;height: 163px" id="yechu'+act_idd+'"><dl class="fix" style="border-butte: 1px solid #eee;"><div style="border-bottom: 1px solid #eee;height: 105px;"><dt><img style="width:72px; height:72px;" src="'+act_share_url+'" /></dt>';
                    }else{
                        htmlye += '<div style="background: #fff;border-bottom: 11px solid #F7F7F7;margin-bottom:10px;height: 163px" id="yechu'+act_idd+'"><dl class="fix" style="border-top: 1px solid #eee;"><div style="border-bottom: 1px solid #eee;height: 105px;"><dt><img style="width:72px; height:72px;" src="'+act_head_pic+'" /></dt>';
                    }

                    htmlye += '<dd id="bm_ziding"><p>'+act_yename+'</p>';
                    htmlye += '<i>'+act_concent+'</i></dd></div></dl></div>';
                }
                $('#bm_yewuxian').html(html);
                $('#bm_yewushow').html(htmlye);

                for(var j in tuijainActivity){
                    var act_tuijianId = tuijainActivity[j].id;
                    var act_names = tuijainActivity[j].name;

                    var act_tuipic = tuijainActivity[j].head_pic;
                    var act_tuiname = tuijainActivity[j].name;
                    var act_endt = tuijainActivity[j].end_time;
                    var act_count = tuijainActivity[j].join_num;
                    var act_web_tuiurl = tuijainActivity[j].web_url;
                    var act_browserenshu = tuijainActivity[j].browse_num;
                    var act_share_url = tuijainActivity[j].share_pic;


                    htmltui += '<li id="shan'+act_tuijianId+'" class="deletehuo" tid="'+act_tuijianId+'">'+act_names+'<img src="<%=path%>/images/marketing/close.png" class="x_lista" id="shan'+act_tuijianId+'" tid="'+act_tuijianId+'"></li>';

                    if(StringEmpty(act_share_url)){
                        htmljian += '<div class="k_content" id="chu'+act_tuijianId+'"><dl class="fix"><dt><img style="width:72px; height:72px;" src="'+act_share_url+'"/></dt>' ;
                    }else{
                        htmljian += '<div class="k_content" id="chu'+act_tuijianId+'"><dl class="fix"><dt><img style="width:72px; height:72px;" src="'+act_tuipic+'"/></dt>' ;
                    }
                    htmljian += '<dd><p>'+act_tuiname+'<i>进行中</i></p>';
                    if(StringEmpty(act_endt)){
                        htmljian += '<em style="margin-top:4px;">有效期至：'+act_endt+'</em></dd></dl>';
                    }else{
                        htmljian += '<em style="margin-top:4px;"></em></dd></dl>';
                    }
                    //htmljian += '<em>有效期至：'+(act_endt!=undefined?act_endt:"")+'</em></dd> </dl>';
                    htmljian += '<ol class="fix">';
                    htmljian += '<div><li class="s_partake" style="display:none">'+act_count+'人参与</li>';
                    htmljian += '<li class="s_like" style="display:none"><img class="s_dianzan_img" src="<%=path%>/images/marketing/dianzan.png" _id="1" />'+act_browserenshu+'</li></div></ol></div>';

                }
                $('#bm_tuijan').html(htmltui);
                $('#bm_xianshi').html(htmljian);
            }
        });
    }
</script>
</body>
</html>